/**
 * @program: LeetCode
 * @description: LeetCode : 剑指 Offer II 006. 排序数组中两个数字之和
 * @author: WXY
 * @create: 2022-12-20 19:23
 * @Version 1.0
 **/

public class offer_two3_twoSum {
    public static int[] twoSum(int[] arr, int target) {
        int left = 0;
        int right = arr.length - 1;
        while (left < right) {
            if (arr[left] + arr[right] < target) {
                left++;
            } else if (arr[left] + arr[right] > target) {
                right--;
            } else {
               break;
            }
        }
        return new int[]{left, right};
    }
}
